using System.Windows;
using System.Windows.Markup;
using SSettings;

namespace SettingsView
{
	public partial class DefaultColorWindow : Window, IComponentConnector
	{
		private ColorSettings _ColorSettings;

		public DefaultColorWindow(ColorSettings colorSettings)
		{
			_ColorSettings = colorSettings;
			if (_ColorSettings != null)
			{
				base.DataContext = _ColorSettings.Clone();
			}
			InitializeComponent();
		}

		private void btnOK_Click(object sender, RoutedEventArgs e)
		{
			if (_ColorSettings != null)
			{
				_ColorSettings.Copy(base.DataContext as ColorSettings);
				_ColorSettings.RaiseUpdateEvent();
			}
			base.DialogResult = true;
			Close();
		}

		private void btnCancel_Click(object sender, RoutedEventArgs e)
		{
			Close();
		}

		private void btnDefault_Click(object sender, RoutedEventArgs e)
		{
			if (base.DataContext is ColorSettings)
			{
				((ColorSettings)base.DataContext).SetDefault();
			}
		}
	}
}
